<template>
	<view class="more-content">
		<view class="content-cell">
			<view class="cell-left" @click="reLaunch('/pages/index/index')">
				<img src="https://img01.yzcdn.cn/vant/cat.jpeg" alt="" />
				<text>邓波测试店铺</text>
			</view>
			<view class="cell-right">
				<u-icon size="20" name="search"></u-icon>
				
				
				
				<text @click="reLaunch('/pages/my/index')">个人中心</text>
			</view>
		</view>
		
		
		<scroll-view scroll-y="true" style="height: 100%;" refresher-enabled="true" :refresher-triggered="refresh"
			@refresherrefresh="onRefresh">
			<view class="cate-list">
				<view class="cate-list-record" v-for="item in columndata" :key="item.id" @click="jump(item)">
					<view class="">
						<u--image :src="item.cover || errorProduct" width='110px' height='90px' mode="aspectFit"
							:errorIcon="errorProduct">

						</u--image>
					</view>

					<view class="cate-list-inform">
						<view class="inform-title">
							{{item.title}}
						</view>
						<view class="inform-left">
							<view class="inform-price">
								{{item.price == '0.00' ?'免费':item.price}}
								<text v-if="item.marking_price">{{item.marking_price}}</text>
							</view>
							<view class="">
								{{item.view || 0}}次观看
							</view>
						</view>
					</view>
				</view>



			</view>

			<u-loadmore :status="status" :icon-type="iconType" :load-text="loadText" />
		</scroll-view>
	</view>
	<!-- 这里是你的列表内容 -->
	<!-- <view v-for="(item, index) in list" :key="index">{{ item }}</view> -->


	<!-- 	<view>
			<ul v-for="(item, index) in list" :key="index">
				<li style="padding-bottom: 40px;">{{ item.title }}</li>
			</ul>
			<u-loadmore :status="status" :icon-type="iconType" :load-text="loadText" />
		</view> -->



</template>

<script>
	import {
		api_getKnowledgeList3
	} from '@/api/cate.js'
	export default {
		data() {
			return {
				errorProduct: require('@/static/img/default_image.jpg'),
				columndata: [],
				options: {},
				form: {
					limit: 10,
					page: 1,
					status: 1,
					shop_name: "db"
				},

				list: [], // 存储列表数据
				page: 1, // 当前页数
				pageSize: 10, // 每页数据数量
				total: 0, // 总数据条数
				isLoading: false, // 是否正在加载数据
				status: 'loadmore',
				iconType: 'flower',
				loadText: {
					loadmore: '轻轻上拉',
					loading: '努力加载中',
					nomore: '实在没有了'
				},
				refresh: null,
			}

		},
		onLoad(options) {
			this.options = options;
			this.query();
		},
		onReachBottom() {
			let that = this;
			if (this.columndata.length == this.total) return;
			this.status = 'loading';
			this.form.page = ++this.page;
			setTimeout(() => {
				that.query(); //请求的接口数据
				if (this.columndata.length == this.total) this.status = 'nomore';
				else this.status = 'loading';
			}, 2000)
		},

		methods: {
			onRefresh() {
				this.refresh = true;
				// 这里不能直接让refresh直接为false，否则可能会发生下拉加载无法复位的情况
				setTimeout(() => {
					this.form.page = 1;
					this.query();
					this.refresh = false;
				}, 500)
			},
			async query() {
				let res = await api_getKnowledgeList3({
					...this.options,
					...this.form
				})

				if (res.code == 1) {
					const data = res.data;

					if (this.status == 'loading') {
						this.columndata = this.columndata.concat(data.list);

					} else {
						this.form.page = 1;
						this.columndata = data.list;
					}
					// 将返回的数据添加到列表数据中
					this.total = data.count; // 更新总数据条数
					if (this.columndata.length == this.total) this.status = 'nomore';
					else this.status = 'loading';
				} else {
					uni.showToast({
						title: res.msg,
						icon: 'error'
					});
				}
			},

			jump(item) {
				uni.navigateTo({
					url: '/pages/livecontent/index' + `?id=${item.id}`
				})
			},
			reLaunch(url) {
				
				uni.reLaunch({
					url: url
				});
			
			
			},
		}

	}
</script>

<style lang="scss" scoped>
	.more-content {
		.cate-list {
			padding: 10rpx 0;

			.cate-list-record {
				display: flex;
				justify-content: space-between;
				padding: 14rpx 10rpx;
				border-radius: 10rpx;
				box-shadow: 0px 1px 17px 6px rgba(0, 0, 0, 0.1);
				background: #fff;
				margin: 0px 14rpx;
				margin-bottom: 10rpx;

				.cate-list-inform {
					// background: #fff;
					// box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
					flex: 1;
					display: flex;
					flex-direction: column;
					justify-content: space-between;
					padding: 20rpx 16rpx;

					.inform-title {
						font-size: 24rpx;
					}

					.inform-left {
						display: flex;
						justify-content: space-between;

						.inform-price {

							color: red;
						}

						text {
							display: inline-block;
							margin-left: 5px;
							color: #969799;
							font-size: 10px;
							text-decoration: line-through;
						}

						>view {
							font-size: 24rpx;
							color: #969799;
						}
					}


				}
			}


		}
	
	
	
		.content-cell{
			padding: 30rpx 20rpx;
			display: flex;
			justify-content: space-between;
			.cell-left{
				display: flex;
				align-items: center;
				img{
					width: 60rpx;
					height: 60rpx;
					border-radius: 50%;
					padding-right: 8rpx;
				}
				text{
					font-size: 26rpx;
				}
			}
			.cell-right{
				display: flex;
				align-items: center;
				font-size: 26rpx;
				
				text{
					padding-left: 4rpx;
					border-left: 1px solid #999;
				}
			}
		}
	
	
	}
	/deep/ {
		.u-image__error {
			div {
				background-size: contain !important;
				background-position: center center !important;
			}
	
		}
	}
</style>